package top.kpromise.note.modules.user.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.oauth2.common.OAuth2AccessToken;

@Data
public class LoginResult {

    @ApiModelProperty(name = "accessToken" , value = "accessToken")
    private String accessToken;

    @ApiModelProperty(name = "refreshToken" , value = "refreshToken")
    private String refreshToken;

    @ApiModelProperty(name = "tokenType" , value = "token类型")
    private String tokenType;

    @ApiModelProperty(name = "expiresIn" , value = "过期时间")
    private Integer expiresIn;

    public void fromToken(OAuth2AccessToken oAuth2AccessToken) {
        accessToken = oAuth2AccessToken.getValue();
        refreshToken = oAuth2AccessToken.getRefreshToken().getValue();
        tokenType = oAuth2AccessToken.getTokenType();
        expiresIn = oAuth2AccessToken.getExpiresIn();
    }
}
